#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>

void run(int* num, int m,int l)
{
	int i = 0;
	int j = 0;
	int* w = num + m-1;
	int* t=0;
	int* a = &num[l];
	int subtitute[] = { 0 };
	for (i=0,t = w+1; t<=a;t++,i++)
		subtitute[i] = *t;
	/*for (j = 0; j < l - m+1; j++)
		printf("%d ", subtitute[j]);*/
	for (j=0,t = num + i; t <= a; t++,j++)
		*t = num[j];
	/*for (i = 4; i <=6; i++)
		printf("%d ", num[i]);*/
	for (i = 0; i <= l - m; i++,num++)
		*num = subtitute[i];

	

}
int main()
{
	int num[] = { 0 };
	int i = 0;
	int lenth = 0;
	int m = 0;
	scanf("%d", &lenth);
	for (i = 0; i < lenth; i++)
	{
		scanf("%d", &num[i]);
	}
	scanf("%d", &m);
	run(num,m,lenth-1);
	for (i = 0; i < lenth; i++)
	{
		printf("%d ", num[i]);
	}
}



